<?php

namespace fwkit;

use fwkit\Http\Client;
use fwkit\Http\CoClient;

class Http
{
    public static function request(string $method, string $url, int $timeout = 5)
    {
        if (Utils::isCoroutine()) {
            return new CoClient($method, $url, $timeout);
        } else {
            return new Client($method, $url, $timeout);
        }
    }

    public static function get(string $url, int $timeout = 5)
    {
        return static::request('GET', $url, $timeout);
    }

    public static function post(string $url, int $timeout = 5)
    {
        return static::request('POST', $url, $timeout);
    }
}
